package com.gdou.teaching.mapper;

import com.gdou.teaching.dataobject.Achievement;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author bo
 * @date Created in 14:13 2019/7/28
 * @description
 **/
@Mapper
@Repository
public interface AchievementMapper {
    /**
     * 添加成绩记录
     * @param achievement
     * @return int
     */
    int addAchievement(Achievement achievement);

    /**
     * 根据学生成绩ID删除成绩记录
     * @param achievementId
     * @return boolean
     */
    boolean deleteAchievementByAchievementId(Integer achievementId);

    /**
     * 根据课程Id和学生Id删除成绩记录
     * @param courseId
     * @param userId
     * @return
     */
    boolean deleteAchievementByCourseIdAndUserId(Integer courseId,Integer userId);

    /**
     * 更新成绩记录
     * @param achievement
     * @return boolean
     */
    boolean updateAchievement(Achievement achievement);

    /**
     *通过课程名查询成绩记录
     * @param courseName
     * @return List<Achievement>
     */
    List<Achievement> selectAchievementListByCourseName(String courseName);

    /**
     * 通过课程名分页查询成绩记录
     * @param courseName
     * @param offset
     * @param limit
     * @return List<Achievement>
     */
    List<Achievement> selectAchievementListByCourseNameForPage(@Param("courseName") String courseName,@Param("offset")Integer offset, @Param("limit")Integer limit);

    /**
     *通过课程ID查询成绩记录
     * @param courseId
     * @return List<Achievement>
     */
    List<Achievement> selectAchievementListByCourseId(Integer courseId);

    /**
     * 通过课程ID分页查询成绩记录
     * @param courseId
     * @param offset
     * @param limit
     * @return  List<Achievement>
     */
    List<Achievement> selectAchievementListByCourseIdForPage(@Param("courseId") Integer courseId, @Param("offset")Integer offset, @Param("limit")Integer limit);

    /**
     * 通过学生ID查询成绩记录
     * @param userId
     * @return  List<Achievement>
     */
    List<Achievement> selectAchievementListByUserId(Integer userId);

    /**
     * 通过学生ID分页查询成绩记录
     * @param userId
     * @param offset
     * @param limit
     * @return  List<Achievement>
     */
    List<Achievement> selectAchievementListByUserIdForPage(@Param("userId") Integer userId, @Param("offset")Integer offset, @Param("limit")Integer limit);

    /**
     * 通过学生ID和课程ID查询成绩记录
     * @param userId
     * @param courseId
     * @return Achievement
     */
    Achievement selectAchievementByUserIdAndCourserId(Integer userId,Integer courseId);


    /**
     * 通过学生成绩ID查询成绩记录
     * @param achievementId
     * @return Achievement
     */
    Achievement selectAchievementByAchievementId(Integer achievementId);

    /**
     * 根据课程id 查找班级列表.
     * @param courseId
     * @return
     */
    List<Integer> getClazzIdListByCourseId(Integer courseId);

    Integer getCountByCourseId(@Param("courseId")Integer courseId);
    Integer getCountByUserId(@Param("userId")Integer userId);
}
